define(['zepto', 'butterfly/view','../../bsl',
    'text!./speech.html'
], function($, View, bsl, speech) {
    var me = null;

    var view = View.extend({
        events: {
            "tap #back":"back",
            "tap #startRecognize":"startRecognize",
            "tap #openDoc":"OpenDoc"

        },
        render: function() {
            me = this;
        },

        onShow: function() {

            // 绑定自定义事件 滑动切换日历等           


        },

        text:null,
        startRecognize: function() {
            var options = {};
            options.engine = 'iFly';
            text.value = "";
            console.info( "开始语音识别：" );
            bsl.speech.startRecognize( options, function ( s ) {
                console.info( s );
                text.value += s;
            }, function ( e ) {
                console.info( "语音识别失败："+e.message );
            } );
        },

        back: function(e){
            window.history.go(-1);
        },

        OpenDoc : function(e){
           
            window.butterfly.navigate('com.no5.cordovademo/doc/speech', {
                trigger: true
            });
        },

        
    });
    return view;
});
